package c.e.a.c.x;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Typeface;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;
import b.i.k.o;
import com.google.android.material.textfield.TextInputLayout;
import java.util.ArrayList;
import java.util.List;
import java.util.WeakHashMap;

/* compiled from: IndicatorViewController */
public final class n {
    public final Context a;
    public final TextInputLayout b;
    public LinearLayout c;
    public int d;
    public FrameLayout e;
    public int f;
    public Animator g;
    public final float h;
    public int i;
    public int j;
    public CharSequence k;
    public boolean l;
    public TextView m;
    public CharSequence n;
    public int o;
    public ColorStateList p;
    public CharSequence q;
    public boolean r;
    public TextView s;
    public int t;
    public ColorStateList u;
    public Typeface v;

    /* compiled from: IndicatorViewController */
    public class a extends AnimatorListenerAdapter {
        public final /* synthetic */ int a;
        public final /* synthetic */ TextView b;
        public final /* synthetic */ int c;
        public final /* synthetic */ TextView d;

        public a(int i, TextView textView, int i2, TextView textView2) {
            this.a = i;
            this.b = textView;
            this.c = i2;
            this.d = textView2;
        }

        public void onAnimationEnd(Animator animator) {
            n nVar = n.this;
            nVar.i = this.a;
            nVar.g = null;
            TextView textView = this.b;
            if (textView != null) {
                textView.setVisibility(4);
                if (this.c == 1) {
                    textView = n.this.m;
                    if (textView != null) {
                        textView.setText(null);
                    }
                }
            }
            textView = this.d;
            if (textView != null) {
                textView.setTranslationY(0.0f);
                this.d.setAlpha(1.0f);
            }
        }

        public void onAnimationStart(Animator animator) {
            TextView textView = this.d;
            if (textView != null) {
                textView.setVisibility(0);
            }
        }
    }

    public n(TextInputLayout textInputLayout) {
        Context context = textInputLayout.getContext();
        this.a = context;
        this.b = textInputLayout;
        this.h = (float) context.getResources().getDimensionPixelSize(2131165320);
    }

    public void a(TextView textView, int i) {
        if (this.c == null && this.e == null) {
            LinearLayout linearLayout = new LinearLayout(this.a);
            this.c = linearLayout;
            linearLayout.setOrientation(0);
            this.b.addView(this.c, -1, -2);
            this.e = new FrameLayout(this.a);
            this.c.addView(this.e, new LayoutParams(0, -2, 1.0f));
            if (this.b.getEditText() != null) {
                b();
            }
        }
        Object obj = (i == 0 || i == 1) ? 1 : null;
        if (obj != null) {
            this.e.setVisibility(0);
            this.e.addView(textView);
            this.f++;
        } else {
            this.c.addView(textView, new LayoutParams(-2, -2));
        }
        this.c.setVisibility(0);
        this.d++;
    }

    public void b() {
        Object obj = (this.c == null || this.b.getEditText() == null) ? null : 1;
        if (obj != null) {
            LinearLayout linearLayout = this.c;
            EditText editText = this.b.getEditText();
            WeakHashMap weakHashMap = o.a;
            linearLayout.setPaddingRelative(editText.getPaddingStart(), 0, this.b.getEditText().getPaddingEnd(), 0);
        }
    }

    public void c() {
        Animator animator = this.g;
        if (animator != null) {
            animator.cancel();
        }
    }

    public final void d(List<Animator> list, boolean z, TextView textView, int i, int i2, int i3) {
        if (textView != null && z) {
            if (i == i3 || i == i2) {
                float f = (i3 == i ? 1 : null) != null ? 1.0f : 0.0f;
                ObjectAnimator ofFloat = ObjectAnimator.ofFloat(textView, View.ALPHA, new float[]{f});
                ofFloat.setDuration(167);
                ofFloat.setInterpolator(c.e.a.c.c.a.a);
                list.add(ofFloat);
                if (i3 == i) {
                    ObjectAnimator ofFloat2 = ObjectAnimator.ofFloat(textView, View.TRANSLATION_Y, new float[]{-this.h, 0.0f});
                    ofFloat2.setDuration(217);
                    ofFloat2.setInterpolator(c.e.a.c.c.a.d);
                    list.add(ofFloat2);
                }
            }
        }
    }

    public boolean e() {
        if (this.j != 1 || this.m == null || TextUtils.isEmpty(this.k)) {
            return false;
        }
        return true;
    }

    public final TextView f(int i) {
        if (i != 1) {
            return i != 2 ? null : this.s;
        } else {
            return this.m;
        }
    }

    public int g() {
        TextView textView = this.m;
        return textView != null ? textView.getCurrentTextColor() : -1;
    }

    public void h() {
        this.k = null;
        c();
        if (this.i == 1) {
            if (!this.r || TextUtils.isEmpty(this.q)) {
                this.j = 0;
            } else {
                this.j = 2;
            }
        }
        k(this.i, this.j, j(this.m, null));
    }

    /* JADX WARNING: Removed duplicated region for block: B:19:0x0032  */
    public void i(android.widget.TextView r4, int r5) {
        /*
        r3 = this;
        r0 = r3.c;
        if (r0 != 0) goto L_0x0005;
    L_0x0004:
        return;
    L_0x0005:
        r1 = 1;
        if (r5 == 0) goto L_0x000d;
    L_0x0008:
        if (r5 != r1) goto L_0x000b;
    L_0x000a:
        goto L_0x000d;
    L_0x000b:
        r5 = 0;
        goto L_0x000e;
    L_0x000d:
        r5 = 1;
    L_0x000e:
        r2 = 8;
        if (r5 == 0) goto L_0x0026;
    L_0x0012:
        r5 = r3.e;
        if (r5 == 0) goto L_0x0026;
    L_0x0016:
        r0 = r3.f;
        r0 = r0 - r1;
        r3.f = r0;
        if (r0 != 0) goto L_0x0020;
    L_0x001d:
        r5.setVisibility(r2);
    L_0x0020:
        r5 = r3.e;
        r5.removeView(r4);
        goto L_0x0029;
    L_0x0026:
        r0.removeView(r4);
    L_0x0029:
        r4 = r3.d;
        r4 = r4 - r1;
        r3.d = r4;
        r5 = r3.c;
        if (r4 != 0) goto L_0x0035;
    L_0x0032:
        r5.setVisibility(r2);
    L_0x0035:
        return;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.e.a.c.x.n.i(android.widget.TextView, int):void");
    }

    public final boolean j(TextView textView, CharSequence charSequence) {
        TextInputLayout textInputLayout = this.b;
        WeakHashMap weakHashMap = o.a;
        return textInputLayout.isLaidOut() && this.b.isEnabled() && !(this.j == this.i && textView != null && TextUtils.equals(textView.getText(), charSequence));
    }

    public final void k(int i, int i2, boolean z) {
        int i3 = i;
        int i4 = i2;
        boolean z2 = z;
        if (i3 != i4) {
            if (z2) {
                AnimatorSet animatorSet = new AnimatorSet();
                this.g = animatorSet;
                ArrayList arrayList = new ArrayList();
                ArrayList arrayList2 = arrayList;
                int i5 = i;
                int i6 = i2;
                d(arrayList2, this.r, this.s, 2, i5, i6);
                d(arrayList2, this.l, this.m, 1, i5, i6);
                c.e.a.c.a.r(animatorSet, arrayList);
                animatorSet.addListener(new a(i2, f(i), i, f(i4)));
                animatorSet.start();
            } else if (i3 != i4) {
                TextView f;
                if (i4 != 0) {
                    f = f(i4);
                    if (f != null) {
                        f.setVisibility(0);
                        f.setAlpha(1.0f);
                    }
                }
                if (i3 != 0) {
                    f = f(i);
                    if (f != null) {
                        f.setVisibility(4);
                        if (i3 == 1) {
                            f.setText(null);
                        }
                    }
                }
                this.i = i4;
            }
            this.b.v();
            this.b.y(z2, false);
            this.b.F();
        }
    }
}
